package com.atqinke.designpattern.behavioraltype.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @BelongsProject: BasicConnection
 * @BelongsPackage: com.atqinke.designpattern.behavioraltype.iterator
 * @Author: NieHk
 * @CreateTime: 2022-08-29  15:47
 * @Description: 具体的容器类，重写所有的方法
 * @Version: 1.0
 */
public class IteratorContainerImpl implements IteratorContainer  {
    private List list;  // 学生列表

    public IteratorContainerImpl(List list){
        this.list = list;
    }

    @Override
    public void add(Object o) {
        this.list.add(o);
    }

    @Override
    public void remove(Object o) {
        this.list.remove(o);
    }

    @Override
    public ObjectIterator getIterator() {
        return new ObjectIteratorImpl(list);
    }
}
